#include "audiosource.h"
#include "util.h"

typedef struct {
	AUDIOSOURCE source;

	int streampos;
} TESTSOURCE;

static int get_numsamples(AUDIOSOURCE *t) {
	return 100;
}

static int get_samples(AUDIOSOURCE *t, float *target, int numsamples) {
	TESTSOURCE *this=(TESTSOURCE *)t;

	TRACE("* reading at: %d, samples: %d\n",this->streampos,numsamples);

	this->streampos+=numsamples;

	return 0;
}

static void set_streampos(AUDIOSOURCE *t, int pos) {
	TESTSOURCE *this=(TESTSOURCE *)t;

	this->streampos=pos;	
}

int main(void) {
	TESTSOURCE testsource;

	testsource.source.get_numsamples_func=get_numsamples;
	testsource.source.get_samples_func=get_samples;
	testsource.source.set_streampos_func=set_streampos;
	testsource.streampos=0;

	TRACE("initializing audiosource\n");

	AUDIOSOURCE *source=(AUDIOSOURCE*)&testsource;
	audiosource_init(source);

	float target[1024];

	audiosource_set_streampos(source,-50);
	audiosource_get_samples(source,target,40);
	audiosource_get_samples(source,target,40);
	audiosource_get_samples(source,target,40);
	audiosource_get_samples(source,target,40);
	audiosource_get_samples(source,target,40);
	audiosource_get_samples(source,target,40);

	return 0;
}